public class SqList<T>implements LList<T>{
    protected Object[] element;//存储空间    
    protected int len;//线性表长度
   
    public SqList(int maxSize){
        len=0;
        element=new Object[maxSize];
    }
    public boolean isEmpty() {
       
        return len==0;
    }

    @Override
    public int length() {
       
        return len;
    }

    @SuppressWarnings("unchecked")
    public T get(int i) {
        if(i<0||i>len-1){
            System.out.println("第i个不存在");
        }
        return (T)element[i];
    }

    @Override
    public void set(int i, T x) {
        element[i]=x;
    }

    @Override
    public void insert(int i, T x) {
        if(len==element.length){
            System.out.println("顺序已满");
        }
        if(i<0||i>len){
            System.out.println("不合法");
        }
        for(int j=len;j>i;j--){
            element[j]=element[j-1];
            element[i]=x;
            len++;
        }

    }

    @Override
    public void append(T x) {
        element[len++]=x;

    }

    @SuppressWarnings("unchecked")
    public T remove(int i) {
       if(i<0||i>len-1){
           System.out.println("不合法");
       }
       for(int j=i;j<len-1;j++){
           element[j+1]=element[j];
           if(j==i){
               
        }
       }
       len--;
        return (T)element[i];
    }

    @Override
    public void removeAll() {
        len=0;

    }

    @Override
    public T search(T key) {
        int j=0;
        
        return null;
    }

    @Override
    public boolean contain(T x) {
       
        return false;
    }

    @Override
    public void showListInfo() {
       

    }
    
}
